<!DOCTYPE html>
<html class="loginHtml">
<head>
	<meta charset="utf-8">
	<title>医院后台管理</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<!--<link rel="icon" href="/favicon.ico">-->
	<link rel="stylesheet" href="/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="/css/public.css" media="all" />
	<style>
		body, html {
			position: absolute;
			top: 0;
			bottom: 0;
			left: 0;
			right: 0;

			margin: 0;
			padding: 0;
		}
		#background {
			position: fixed;
			top: 0;
			left: 0;

			z-index: -100;
		}
	</style>
</head>
<body class="loginBody" >
<canvas id="background"></canvas>

	<form class="layui-form" lay-filter="login">
		<div class="layui-form-item input-item"><h3 style="text-align: center;margin-top: 20px;margin-bottom: 20px">管理员登陆</h3></div>
		<div class="layui-form-item input-item">
			<label for="userName">用户名</label>
			<input type="text" placeholder="请输入用户名" autocomplete="off" id="userName" class="layui-input" lay-verify="required" name="username">
		</div>
		<div class="layui-form-item input-item">
			<label for="password">密码</label>
			<input type="password" placeholder="请输入密码" autocomplete="off" id="password" class="layui-input" lay-verify="required" name="password">
		</div>

		<div class="layui-form-item">
			<button lay-submit lay-filter="login" class="layui-btn" style="margin-left: 80px;">立即登录</button>
		</div>

	</form>


	<script type="text/javascript" src="/layui/layui.js"></script>
	<script type="text/javascript" src="/js/background.min.js"></script>
	<script type="text/javascript" src="/js/cache.js"></script>
	<script src="/layui/layui.js"></script>
	<script src="/js/config.js"></script>
	<script src="/js/json2.js"></script>
	<script type="text/javascript">
        layui.use(['form','layer','jquery'],function(){
            var form = layui.form,
                layer = parent.layer === undefined ? layui.layer : top.layer
            $ = layui.jquery;



            //表单输入效果
            $(".loginBody .input-item").click(function(e){
                e.stopPropagation();
                $(this).addClass("layui-input-focus").find(".layui-input").focus();
            })
            $(".loginBody .layui-form-item .layui-input").focus(function(){
                $(this).parent().addClass("layui-input-focus");
            })
            $(".loginBody .layui-form-item .layui-input").blur(function(){
                $(this).parent().removeClass("layui-input-focus");
                if($(this).val() != ''){
                    $(this).parent().addClass("layui-input-active");
                }else{
                    $(this).parent().removeClass("layui-input-active");
                }
            })
        })

	</script>
<script type="text/javascript">
    layui.use(['form','layer','jquery'], function () {

        // 操作对象
        var form = layui.form;
        var $ = layui.jquery;
        form.on('submit(login)',function (data) {
            console.log(data.field);
            console.log(data.form);
            $.ajax({
                url:new Config().base_url + '/user/Adminlogin',
                data:data.field,
                dataType:'json',
                type:'post',
                success:function (d) {
                    if (d.code == 0){
                        //放入本地存储
                        sessionStorage.setItem("login_user",JSON.stringify(d.data))
                        layer.msg('登录成功！', {
                            icon: 1,
                            time: 1000 //2秒关闭（如果不配置，默认是3秒）
                        }, function(){
                            location.href = "/Adminindex.html";
                        });
                    }else{
                        layer.msg(d.msg);
                    }
                }
            })
            return false;
        })
    });
</script>

</body>